<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		.box{
			width:200px;
			height: 200px;
			background: red url() 0 0 no-repeat;
		}

	</style>
	<script type="text/javascript">
		window.onload = function () {

			var box = document.getElementById('box');
			//获取外部的样式

			var btn  = document.getElementById('btn');


			btn.onclick = function(){
				if(btn.value=="开始"){

					btn.value="结束";

					aa = setInterval(run,10)

				}else{
					btn.value="开始";

					clearInterval(aa);
				}
			}

			var width=200;

			var is_add= true;

			function run () {
				

				if(is_add){
					width+=5
				}else{
					width-=5
				}

				if(width>400){
					is_add = false;
				}else if(width<200){
					is_add = true;
				}

				box.style.width=width+'px'
				box.style.height=width+'px'
			}


		}
	</script>
</head>
<body>
	<input type="button" id="btn" value="开始">
	<div class="box"  id="box"></div>
</body>
</html>